package com.oro.domain;

import static javax.persistence.CascadeType.ALL;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;

/**
 * Entity implementation class for Entity: Categoria
 * 
 */
@Entity
public class Categoria implements Serializable {

	public static final Categoria AGED_CARE_CERT_I = new Categoria(
			"Aged Care Cert. I", MacroCategoria.CERTIFICATION);
	public static final Categoria AGED_CARE_CERT_II = new Categoria(
			"Aged Care Cert. II", MacroCategoria.CERTIFICATION);
	public static final Categoria AGED_CARE_CERT_III = new Categoria(
			"Aged Care Cert. III", MacroCategoria.CERTIFICATION);
	public static final Categoria BAR_ENGLISH = new Categoria("English - Bar",
			MacroCategoria.ENGLISH);
	public static final Categoria BAR_SKILLS = new Categoria("Bar Skills",
			MacroCategoria.VOCATIONAL);
	public static final Categoria CAMBRIDGE = new Categoria("Cambridge",
			MacroCategoria.ENGLISH);
	public static final Categoria CCENT = new Categoria(
			"CCENT - Cisco Certified Network Associate",
			MacroCategoria.CERTIFICATION);
	public static final Categoria CCNA = new Categoria(
			"CCENT - Cisco Certified Entry Networking Technician",
			MacroCategoria.CERTIFICATION);
	public static final Categoria ELICOS_ENGLISH = new Categoria(
			"Elicos - English", MacroCategoria.ENGLISH);
	public static final Categoria GENERAL_ENGLISH = new Categoria(
			"General English", MacroCategoria.ENGLISH);
	public static final Categoria GENERAL_ENGLISH_ADVANCED = new Categoria(
			"General English - Advanced", MacroCategoria.ENGLISH);
	public static final Categoria GENERAL_ENGLISH_BEGINNER = new Categoria(
			"General English - Beginner", MacroCategoria.ENGLISH);
	public static final Categoria GENERAL_ENGLISH_INTERMEDIATE = new Categoria(
			"General English - Intermediate", MacroCategoria.ENGLISH);
	public static final Categoria IELTS = new Categoria("IELTS",
			MacroCategoria.ENGLISH);
	public static final Categoria NON_ELICOS_ENGLISH = new Categoria(
			"Non Elicos - English", MacroCategoria.ENGLISH);
	public static final Categoria RSA = new Categoria(
			"RSA - Responsible Service of Alcohol",
			MacroCategoria.CERTIFICATION);
	private static final long serialVersionUID = 1L;

	public static final Categoria VET_PROFESSIONAL = new Categoria(
			"VET - Professional", MacroCategoria.PROFESSIONAL);

	@Id
	@GeneratedValue
	private Long id;

	@ManyToOne(cascade = ALL)
	@JoinTable(name = "categoria_macrocategoria")
	// Uni-directional
	private MacroCategoria macroCategoria;

	private String name;

	public Categoria() {
		super();
	}

	public Categoria(String name) {
		this();
		this.name = name;
	}

	public Categoria(String name, MacroCategoria macroCategoria) {
		this(name);
		this.macroCategoria = macroCategoria;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o != null)
			if (o instanceof Categoria)
				if (getId() != null)
					return getId().equals(((Categoria) o).getId());
				else
					return this.name.equals(((Categoria) o).getName())
							&& this.getMacroCategoria().equals(
									((Categoria) o).getMacroCategoria());
			else
				return false;
		else
			return false;
	}

	public Long getId() {
		return id;
	}

	public MacroCategoria getMacroCategoria() {
		return macroCategoria;
	}

	public String getName() {
		return name;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setMacroCategoria(MacroCategoria macroCategoria) {
		this.macroCategoria = macroCategoria;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public String toString() {
		if (getId() != null && getId() != 0L)
			return getId().toString();
		else
			return super.toString();
	}
}
